package com.course.android.ui.fragment;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.baselib.android.utils.ToastTool;
import com.course.android.R;
import com.course.android.ui.adapter.WebNewsAdapter;
import com.course.controller.NewsController;
import com.course.model.HttpConfigBean;

import java.util.List;

public class MilitaryFragment extends BaseNewsNetFragment {


    WebNewsAdapter webNewsAdapter;

    @Override
    protected void initView(View view) {
        initLv(view);
        webNewsAdapter = new WebNewsAdapter();
        lvView.setAdapter(webNewsAdapter);  // 设置循环视图的线性适配器

    }
    @Override
    public RecyclerView.LayoutManager getLayoutManager() {
        LinearLayoutManager manager = new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false);
        return manager;
    }


    @Override
    protected void initEvent() {

    }

    @Override
    protected void initData() {
        NewsController.getInstance().query(this,"military",pageNum,pageSize);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_news;
    }

    @Override
    protected void lazyLoad() {

    }

    @Override
    public <T> void onData(HttpConfigBean flag, T o) {

    }

    @Override
    public <NewsVo> void onPageData(HttpConfigBean flag, int pageNum,
      int pageSize, int total, List<NewsVo> array) {
        ToastTool.show(getActivity(),"12345");
        webNewsAdapter.setData((List<com.course.model.resp.NewsVo>) array);
    }
    @Override
    public void loadNext() {
        NewsController.getInstance().query(this,"military",pageNum,pageSize);
    }
}
